package com.service.Authorization.service.impl;

import com.service.Authorization.dao.UserCipherInfoDao;
import com.service.Authorization.entity.UserCipherInfo;
import com.service.Authorization.service.UserCipherInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 有密码认证信息(UserCipherInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-08-10 16:14:35
 */
@Service("userCipherInfoService")
public class UserCipherInfoServiceImpl implements UserCipherInfoService {
    @Resource
    private UserCipherInfoDao userCipherInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserCipherInfo queryById(String id) {
        return this.userCipherInfoDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<UserCipherInfo> queryAllByLimit(int offset, int limit) {
        return this.userCipherInfoDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userCipherInfo 实例对象
     * @return 实例对象
     */
    @Override
    public UserCipherInfo insert(UserCipherInfo userCipherInfo) {
        this.userCipherInfoDao.insert(userCipherInfo);
        return userCipherInfo;
    }

    /**
     * 修改数据
     *
     * @param userCipherInfo 实例对象
     * @return 实例对象
     */
    @Override
    public UserCipherInfo update(UserCipherInfo userCipherInfo) {
        this.userCipherInfoDao.update(userCipherInfo);
        return this.queryById(userCipherInfo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.userCipherInfoDao.deleteById(id) > 0;
    }

    @Override
    public UserCipherInfo queryByUserId(String id) {
        return userCipherInfoDao.queryByUserId(id);
    }

    @Override
    public UserCipherInfo queryByPassword(String randomNum) {
        return userCipherInfoDao.queryByPassword(randomNum);
    }
}
